package com.example.mp.utils;

import org.jasypt.util.text.BasicTextEncryptor;

/**
 * @Author hf
 * @ClassName: JasyptEncryptionUtils
 * @Description: TODO (Jasypt加密工具类)
 * @Date 2021/7/28 17:41
 * @Copyright 新智道枢(上海)科技有限公司
 * @Version 1.0
 */
public class JasyptEncryptionUtils {

    public static boolean encrypt() {
        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
        //加密所需的salt(盐)
        textEncryptor.setPassword("abcd");
        //要加密的数据（数据库的用户名或密码）
        String username = textEncryptor.encrypt("root");
        String password = textEncryptor.encrypt("123456");
        System.out.println("username:" + username);
        System.out.println("password:" + password);
        return false;
    }

    public static boolean decrypt() {
        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
        //加密所需的salt(盐)
        textEncryptor.setPassword("abcd");
        //要加密的数据（数据库的用户名或密码）
        String username = textEncryptor.decrypt("XpfWaVaL9WVF3d1aSOV2+w==");
        String password = textEncryptor.decrypt("KAnTpPvIm9e8SOLWagTwmw==");
        System.out.println("username:" + username);
        System.out.println("password:" + password);
        return false;
    }

}
